﻿@namespace Microsoft.AspNetCore.Components
@inherits ComponentBase
@using System.IOFrancis.FileSystem

<Media>
    @{
        var src = MediaAttributes?.TryGetValue("src").Value?.ToString();
        var isVideo = src.IsVoid() || FileTypeCom.WebVideo.IsCompatible(src);
    }
    @if (isVideo)
    {
        <video id="@context.ID" onended="@context.OnEndedScript"
               onloadedmetadata="=@context.OnLoadedMetaDataScript"
               ontimeupdate="@context.OnTimeUpDateScript"
               onvolumechange="@context.OnVolumeChangeScript"
           @attributes=MediaAttributes />
    }
    else
    {
        <audio id="@context.ID" onended="@context.OnEndedScript"
               onloadedmetadata="=@context.OnLoadedMetaDataScript"
               ontimeupdate="@context.OnTimeUpDateScript"
               onvolumechange="@context.OnVolumeChangeScript"
           @attributes=MediaAttributes />
    }
</Media>